import Sequelize from 'sequelize';
import baseDao from '../lib/baseDao.js'; // 数据库操作

const Modal = baseDao.sequelize.define('t_user', {
  // 属性
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true, // 主键
    autoIncrement: true, // 自增
    allowNull: true,
    validate: {
      len: [1, 50]
    }
  },
  username: {
    type: Sequelize.STRING,
    unique: true, // 唯一约束
    allowNull: false,
    validate: {
      len: [0, 20]
    },
    comment: '用户名'
  },
  password: {
    type: Sequelize.STRING,
    allowNull: false,
    validate: {
      len: [0, 20]
    },
    comment: '密码'
  },
  mobile: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [11, 11]
    },
    comment: '手机号'
  },
  email: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '邮箱号'
  },
  permission: {
    type: Sequelize.STRING,
    allowNull: false,
    validate: {
      len: [0, 10]
    },
    comment: '用户类型，销售员seller，管理员admin，物流操作员deliveryOperator，物流供应商deliverySupplier，物料供应商materialSupplier'
  },
  level: {
    type: Sequelize.INTEGER,
    allowNull: false,
    validate: {
      len: [0, 5]
    },
    defaultValue: 1,
    comment: '客户等级,最低为1'
  },
  avatar: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 100]
    },
    comment: '用户头像'
  }
}, {
    // 参数
  });

//向外暴露
export default{
  Modal,
}